using Inventory;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class UpgradeHoloLance:Upgrade {

	protected override void ProjectileDecidingEventHandler(object _sender,ShootEventArgs e) {
		base.ProjectileDecidingEventHandler(_sender,e);
		if(!IfReactWeaponEvent(_sender,e)) return;
		e.stat.currentProjectile=ProjectileData.nameToData["HoloLance"];
	}

	protected override void ProjectileFiringEventHandler(object _sender,ProjectileEventArgs e) {
		base.ProjectileFiringEventHandler(_sender,e);
		if(!IfReactProjectileEvent(_sender,e)) return;
		Projectile sender = (_sender as Projectile);
		ModifierDropItem newModifier = new ModifierDropItem(sender,null);
		newModifier.SetItem(new ItemUpgrade(boundInstance));
		sender.AddModifier(newModifier);
		weapon.TryRemoveUpgrade(boundInstance);
	}

}

public class ModifierDropItem:ProjectileModifier {

	static ModifierDropItem() {
		SetDescriptions(
			typeof(ModifierDropItem),
			"",
			"",
			null
		);
	}

	public ModifierDropItem(Projectile owner,string[] parameters) : base(owner,parameters) {

	}
	ItemBase content;
	public void SetItem(ItemBase content) => this.content=content;

	protected override void SubscribeEvents() {
		base.SubscribeEvents();
		ProjectileEventHelper.destroy.SubscribeSingle(owner,Projectile_Destroy);
	}
	protected override void UnsubscribeEvents() {
		base.UnsubscribeEvents();
		ProjectileEventHelper.destroy.UnsubscribeSingle(owner,Projectile_Destroy);
	}

	void Projectile_Destroy(object _sender,ProjectileEventArgs e) {
		ItemPickup.Create(owner.transform.position,content);
	}

}